# -*- codeing = utf-8 -*-
# @Time : 2023/2/24 10:30
# @Author : 小马
# @File: enemy.py
# @Software : PyCharm
import pygame.sprite
import random


class enemy(pygame.sprite.Sprite):
    def __init__(self):
        super(enemy,self).__init__()
        self.image=pygame.image.load('material/b5.1.PNG').convert_alpha()
        self.images=[pygame.image.load('material/b5.{:d}.png'.format(i)).convert_alpha() for i in range(1,16)]
        self.rect = self.images[0].get_rect()
        t = random.randint(1, 5)
        self.rect.top = t*100
        self.speed = 3
        self.rect.left = 1200

        self.blood=1



    def update(self, *args):
        if self.blood>0:
         self.image=self.images[args[0]%len(self.images)]

         if self.rect.left<600:
            self.kill()
         else:
            self.rect.left -= self.speed
        else:
            self.kill()